package com.xxjqr.rbac.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum SexEnum implements BaseEnum {
    MALE(1,"男"),
    FEMALE(0,"女"),
    UNKNOW(2,"未知")
    ;
    @EnumValue
    @JsonValue
    private final Integer code;
    private final String desc;

    @Override
    public String getName() {
        return name();
    }

    @JsonCreator
    public SexEnum valueOf(int code) {
        for (SexEnum value : values()) {
            if (value.code == code) {
                return value;
            }
        }
        return null;
    }
}
